﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NSEEOD_downloader.Tasks;

namespace NSEEOD_downloader
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            TrayNotify.Visible = true;
            this.Hide();
        }

        private void btnSettings_Click(object sender, EventArgs e)
        {
            Settings option = new Settings();
            option.ShowDialog();
        }   

        private void btnEOD_Click(object sender, EventArgs e)
        {
            FormDownload download = new FormDownload();
            download.DownloadLink = Utils.GetString(Application.UserAppDataRegistry.GetValue(NSEEODTask.SETTINGS_PARSELINK));
            if (download.DownloadLink.Length <= 1)
            {
                MessageBox.Show("Download link format is not specified,\nPlease goto Settings and update the link");
                return;
            }
            download.DataDir = Utils.GetString(Application.UserAppDataRegistry.GetValue("DATA_DIR"));
            if (download.DataDir.Length <= 1)
            {
                MessageBox.Show("Download data directory is not specified,\nPlease goto Settings and specify the directory");
                return;
            }
            download.CurrentTask = new NSEEODTask();
            download.ShowDialog();
        }

        private void btnFOEOD_Click(object sender, EventArgs e)
        {
            FormDownload download = new FormDownload();
            download.DownloadLink = Utils.GetString(Application.UserAppDataRegistry.GetValue(NSEFOEODTask.SETTINGS_PARSELINK));
            if (download.DownloadLink.Length <= 1)
            {
                MessageBox.Show("Download link format is not specified,\nPlease goto Settings and update the link");
                return;
            }
            download.DataDir = Utils.GetString(Application.UserAppDataRegistry.GetValue("DATA_DIR"));
            if (download.DataDir.Length <= 1)
            {
                MessageBox.Show("Download data directory is not specified,\nPlease goto Settings and specify the directory");
                return;
            }
            download.CurrentTask = new NSEFOEODTask();
            download.ShowDialog();
        }

        private void btnEEOD_Click(object sender, EventArgs e)
        {
            Utils.NotImplemented();
        }

        private void TrayNotify_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            this.Show();
        }
    }
}
